import sys
import os
from pathlib import Path
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import QSettings
from PySide6.QtGui import QIcon
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtQuickControls2 import QQuickStyle
import platform
import Bridge
def main():
    if platform.uname().system=="Windows":
        pass
    QApplication.setApplicationName("装箱单")
    QApplication.setOrganizationName("QtProject")

    app = QApplication(sys.argv)
    # QIcon.setThemeName("gallery")
    settings = QSettings()
    if not os.environ.get("QT_QUICK_CONTROLS_STYLE"):
        style_name = settings.value("style")
        if style_name:
            QQuickStyle.setStyle(style_name)
    # QQuickStyle.setStyle("Material")
    engine = QQmlApplicationEngine()
    qml_file = Path(__file__).parent / 'assets/main.qml'
    r=engine.rootContext()
    # print(dir(r))
    b=Bridge.Bridge()
    r.setContextProperty("pingPong", b);
    engine.load(qml_file)

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec())
if __name__ == '__main__':
    main()
    
